package com.jf.controller;

import com.alibaba.fastjson.JSON;
import com.jf.service.*;
import com.jf.service.impl.*;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/front/data")
public class FrontDataServlet extends HttpServlet {
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String param = request.getParameter("param");

        SchoolService schoolService = new SchoolServiceImpl();
        EnterpriseService enterpriseService = new EnterpriseServiceImpl();
        TeacherService teacherService = new TeacherServiceImpl();
        BannerService bannerService = new BannerServiceImpl();
        Project2Service project2Service = new Project2ServiceImpl();
        if("school".equals(param)){
            response.getWriter().println(JSON.toJSON(schoolService.getList()));
        }
        if("enterprise".equals(param)){
            response.getWriter().println(JSON.toJSON(enterpriseService.getInfo()));
        }

        if("teacher".equals(param)){
            response.getWriter().println(JSON.toJSON(teacherService.getList()));
        }

        if("banner".equals(param)){
            response.getWriter().println(JSON.toJSON(bannerService.getList()));
        }

        if("project".equals(param)){
            response.getWriter().println(JSON.toJSON(project2Service.getList()));
        }

    }
}
